package com.xxx.landlord.client.view;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import java.io.IOException;

public class StartView {

    @FXML
    private Button startButton;

    @FXML
    private Button exitButton;

    // 初始化方法
    @FXML
    public void initialize() {
        setupButtonHoverEffects();
    }

    // 设置按钮悬停效果
    private void setupButtonHoverEffects() {
        startButton.setOnMouseEntered(e -> {
            startButton.setScaleX(1.05);
            startButton.setScaleY(1.05);
        });

        startButton.setOnMouseExited(e -> {
            startButton.setScaleX(1.0);
            startButton.setScaleY(1.0);
        });

        exitButton.setOnMouseEntered(e -> {
            exitButton.setScaleX(1.05);
            exitButton.setScaleY(1.05);
        });

        exitButton.setOnMouseExited(e -> {
            exitButton.setScaleX(1.0);
            exitButton.setScaleY(1.0);
        });
    }

    // 开始按钮点击事件
    @FXML
    private void handleStartButton(ActionEvent event) {
        try {
            System.out.println("开始游戏按钮被点击");

            FXMLLoader loader = new FXMLLoader(getClass().getResource("SelectModeView.fxml"));
            Parent selectModeRoot = loader.load();

            Stage stage = (Stage) startButton.getScene().getWindow();
            stage.setScene(new Scene(selectModeRoot));
            stage.setTitle("选择游戏模式");
            stage.show();

        } catch (IOException e) {
            System.err.println("无法加载游戏模式选择界面: " + e.getMessage());
            e.printStackTrace();
        }
    }

    // 退出按钮点击事件
    @FXML
    private void handleExitButton(ActionEvent event) {
        System.out.println("退出游戏按钮被点击");

        Stage stage = (Stage) exitButton.getScene().getWindow();
        stage.close();
    }
}